package cn.wusifx.zabbix.request.builder.script;

import cn.wusifx.zabbix.request.BaseRequest;
import cn.wusifx.zabbix.request.builder.GetRequestBuilder;
import cn.wusifx.zabbix.request.builder.RequestBuilder;

import java.util.HashMap;
import java.util.Map;

/**
 * https://www.zabbix.com/documentation/4.0/manual/api/reference/script/execute
 */
public class ScriptExecuteRequestBuilder extends RequestBuilder<Map<String,String>> {
    private String hostId;
    private String scriptId;
    public ScriptExecuteRequestBuilder(String auth) {
        super("script.execute", auth);
        baseRequest.setParams(new HashMap<>());
    }

    public ScriptExecuteRequestBuilder(Long id, String auth) {
        super("script.execute", id, auth);
        baseRequest.setParams(new HashMap<>());
    }


    public ScriptExecuteRequestBuilder setParam(String key, String value){
        baseRequest.getParams().put(key,value);
        return this;
    }

    public ScriptExecuteRequestBuilder setParams(Map<String,String> params){
        baseRequest.getParams().putAll(params);
        return this;
    }

    public String getHostId() {
        return hostId;
    }

    public ScriptExecuteRequestBuilder setHostId(String hostId) {
        this.hostId = hostId;
        return this;
    }

    public String getScriptId() {
        return scriptId;
    }

    public ScriptExecuteRequestBuilder setScriptId(String scriptId) {
        this.scriptId = scriptId;
        return this;
    }

    @Override
    public BaseRequest<Map<String, String>> builder() {
        baseRequest.getParams().put("hostid",hostId);
        baseRequest.getParams().put("scriptid",scriptId);
        return baseRequest;
    }
}
